package com.youlu.campus.admin.task;

import com.youlu.campus.service.rank.RankService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

@Slf4j
@Component
public class RankTask {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    @Autowired
    private RankService rankService;
    /**
     * 10分钟执行一次
     */
    @Scheduled(cron = "0 0/10 * * * ?")
    public void doRankJob(){
        log.info("开始执行:排行榜数据");
        Integer hour =12;
        Boolean flag = redisTemplate.opsForValue().setIfAbsent("com.luyou.rank.pre-date", "1", 10L, TimeUnit.MINUTES);
        if(Objects.nonNull(flag)&&!flag){
            return;
        }
    }
}
